package com.stu.day11.factory3.f2;

/**
 * 简单工厂模式实现:
 * 汽车工厂
 * @author zy
 * @date 2025/2/3 20:17
 */
public class CarFactory {
    public static final int LUXURY = 0;
    public static final int ECONOMY = 1;

    public static Car createCar(int type) {
        switch (type) {
            case LUXURY:
                return new LuxuryCar();  // 创建并返回豪华车
            case ECONOMY:
                return new EconomyCar();  // 创建并返回经济车
            default:
                throw new IllegalArgumentException("Unknown car type: " + type);
        }
    }
}


